package com.ny.demo;

public class CarInsurance extends Insurance{
    private double carValue;
    private int accidentCount;

    public CarInsurance(double carValue, int accidentCount) {
        this.carValue = carValue;
        this.accidentCount = accidentCount;
    }

    @Override
    public double calculatePremium() {
        double basePremium = carValue * 0.02;
        if (accidentCount == 0) {
            return basePremium;
        } else if (accidentCount == 1) {
            return basePremium * 1.1;
        } else {
            return basePremium * 1.2;
        }
    }
}
